package com.example.springboot_rabbitmq;

import com.example.springboot_rabbitmq.service.PubSubMessageProducer;
import com.example.springboot_rabbitmq.service.TopicMessageProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application implements CommandLineRunner {
//    @Autowired
//    private PubSubMessageProducer pubSubMessageProducer;
//    public static void main(String[] args) {
//        SpringApplication.run(Application.class, args);
//    }
//    @Override
//    public void run(String... args) throws Exception {
//        pubSubMessageProducer.sendMessage("Publish/Subscribe message");
//    }

    @Autowired
    private TopicMessageProducer topicMessageProducer;
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
    @Override
    public void run(String... args) throws Exception {
        topicMessageProducer.sendMessage("Topic message 1", "topic.key1.sub1");
        topicMessageProducer.sendMessage("Topic message 2", "topic.key2.sub1");
    }

}
